//
//  AuctionAPI.swift
//  LeGou
//
//  Created by lxm on 2022/10/15.
//
import Foundation

enum AuctionAPI {
    // 我要竞购
    case auction(_ params : [String : Any])
    // 出价记录
    case auctionRecrod(_ params : [String : Any])
    // 竞拍详情
    case auctionDetail(_ recordId : Int)
    // 获取出价记录
    case auctionGetRecord(_ params : [String : Any])
    // 我的竞购
    case myAuction(_ params : [String : Any])
    // 获取当前活动列表
    case getActivities(_ params : [String : Any])
    // 获取商品列表
    case getAuctionList(_ params : [String : Any])
    // 余额充值
    case balanceRecharge(_ params : [String : Any])
    // 检查版本号
    case checkVersion(_ recordId : Int)
    // 获取改动数据
    case changeData(_ recordId : Int)
    // 创建订单
    case createOrder(_ params : [String : Any])
    // 统计信息
    case auctionInfo
    // signInfo
    case signInfo
    // 签到记录列表
    case signRecrodList(_ params : [String : Any])
    // 签到
    case signIn(_ param : [String : Any])
    // 合成库列表
    case compoundList(_ param : [String : Any])
    // 获取合成库详情（已合成、已失效）
    case compoundDetail(_ param : [String : Any])
    // 获取合成库详情（合成中）
    case compoundDetailOngoingList(_ param : [String : Any])
    // 获取用户合成开关[0：关闭 1开启]
    case compoundSwitch
    // 立即合成
    case compound(_ param : [String : Any])
    // 修改开关
    case compoundOnSwitch(_ param : [String : Any])
    // 申请发货
    case applySend(_ param : [String : Any])
    // 兑换积分
    case exchangeIntegral(_ param : [String : Any])
    // 获取自动竞购时间
    case autoTime(_ param : [String : Any])
    // 获取自动专区竞购商品列表
    case getAutoGoods
    // 立即报名（一键报名）
    case enroll(_ param : [String : Any])
    // 自动详情
    case autoDetail(_ param : [String : Any])
    // 获取合成记录
    case getConflateRecord(_ param : [String : Any])
    // 恢复
    case recoverAutoAuction(_ param : [String : Any])
}

extension AuctionAPI: ZMApiProvider {
    func BaseUrl() -> String {
        return baseUrl
    }
    
    func urlAndMthodAndParam() -> (url: String, method: ZMHTTPMethod, params: [String : Any], body: Bool) {
        switch self {
        case .auction(let pa):
            return ("/api/front/ah/beat", .post, pa, true)
        case .auctionRecrod(let pa):
            return ("/api/front/ah/bidRecord", .get, pa, false)
        case .auctionDetail(let recordId):
            return ("/api/front/ah/detail/\(recordId)", .get, [:], false)
        case .auctionGetRecord(let pa):
            return ("/api/front/ah/getBidRecord/\(JSON(pa)["recordId"].intValue)", .get, pa, false)
        case .myAuction(let pa):
            return ("/api/front/ah/myBid", .get, pa, false)
        case .getActivities(let pa):
            return ("/api/front/ah/getActivityList", .get, pa, false)
        case .getAuctionList(let pa):
            return ("/api/front/ah/getGoods", .get, pa, false)
        case .balanceRecharge(let pa):
            return ("/api/front/user/balance/recharge", .post, pa, true)
        case .checkVersion(let recordId):
            return ("/api/front/ah/getDetailVersion/\(recordId)", .get, [:], false)
        case .changeData(let recordId):
            return ("/api/front/ah/detailRefresh/\(recordId)", .get, [:], false)
        case .createOrder(let pa):
            return ("/api/front/ah/createOrder", .post, pa, true)
        case .auctionInfo:
            return ("/api/front/ah/getRewardStat", .get, [:], false)
        case .signInfo:
            return ("/api/front/ahSign/getSignInfo", .get, [:], false)
        case .signRecrodList(let pa):
            return ("/api/front/ahSign/signRecord", .get, pa, false)
        case .signIn(let pa):
            return ("/api/front/ahSign/signIn", .post, pa, true)
        case .compoundList(let pa):
            return ("/api/front/ah/getUserConflateList", .get, pa, false)
        case .compoundDetail(let pa):
            return ("/api/front/ah/getConflateAfterDetail", .get, pa, false)
        case .compoundDetailOngoingList(let pa):
            return ("/api/front/ah/getConflateDetail", .get, pa, false)
        case .compoundSwitch:
            return ("/api/front/ah/getUserConflateSwitch", .get, [:], false)
        case .compound(let pa):
            return ("/api/front/ah/operationConflate", .post, pa, true)
        case .compoundOnSwitch(let pa):
            return ("/api/front/ah/updateUserConflateSwitch", .put, pa, false)
        case .applySend(let pa):
            return ("/api/front/ah/applyDeliverGoods", .post, pa, true)
        case .exchangeIntegral(let pa):
            return ("/api/front/ah/exchangeIntegral", .post, pa, true)
        case .autoTime(let pa):
            return ("/api/front/ah/getAutoBidTime", .get, pa, false)
        case .getAutoGoods:
            return ("/api/front/ah/getAutoGoodsList", .get, [:], false)
        case .enroll(let pa):
            return ("/api/front/ah/enroll", .post, pa, true)
        case .autoDetail(let pa):
            return ("/api/front/ah/getAutoDetail", .get, pa, false)
        case .getConflateRecord(let pa):
            return ("/api/front/ah/getConflateRecord", .get, pa, false)
        case .recoverAutoAuction(let pa):
            return ("/api/front/ah/recovery", .post, pa, true)            
        }
    }
    
    func HTTPHeader() -> ZMHTTPHeaders? {
        return AppHelper.reqeustHeader()
    }
    
    func UpLoadData() -> [Data]? {
        return nil
    }
    
    func ParamInBody() -> Bool {
        switch self {
//            return true
        default:
            return false
        }
    }
}
